def _write_private_key_file(self, tag, filename, data, password=None):
f = open(filename, '<STR_LIT:w>', <NUM_LIT>)<EOL>os.chmod(filename, <NUM_LIT>)<EOL>self._write_private_key(tag, f, data, password)<EOL>f.close()<EOL>
Write an SSH2-format private key file in a form that can be read by
ssh or openssh.  If no password is given, the key is written in
a trivially-encoded format (base64) which is completely insecure.  If
a password is given, DES-EDE3-CBC is used.

@param tag: C{"RSA"} or C{"DSA"}, the tag used to mark the data block.
@type tag: str
@param filename: name of the file to write.
@type filename: str
@param data: data blob that makes up the private key.
@type data: str
@param password: an optional password to use to encrypt the file.
@type password: str

@raise IOError: if there was an error writing the file.