Fix using ByteArray.writeBytes when bytes.length is 0