Fixing writing bytes