Fixed the write file function to allow for specifying write type on file io so we can write binary files (images) in ruby 1.9+