helper class to write binary files