Writes a custom sized integer primitive to the file. This method returns a negative value if it fails.