make sure we write all bytes