Fixed bug when writing a byte array.