Fixed the write file function to allow for specifying open type

Need to specify "wb" when wanting to write binary files.
Issue  popped up in a Ruby migration from 1.8.7

This defaults to current behavior, allows one to specify 
write type in the function.