Fixed bug where some bytes were swapped in output file.