That should work too:
data = "BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03" # write to file File.binwrite("path/to/file", data) # read from file File.binread("path/to/file") == data