use bytes to write to file