in reply to permissions, open and chown

You can set your umask using umask.

For example, if you want 0666, use umask 0 (or 0111). For 0655, use umask 022.

At least on Linux, this won't create files with +x set. But that may be platform dependent.
--
Mike

(Edit: Added note about +x not getting set, after actually testing my code :))