protected void writeAMF3ByteArray(byte[] bytes) throws IOException {
    	if (debugMore) debug("writeAMF3ByteArray(bytes=", bytes, ")");

        write(AMF3_BYTEARRAY);

        int index = indexOfStoredObjects(bytes);
        if (index >= 0)
            writeAMF3IntegerData(index << 1);
        else {
            addToStoredObjects(bytes);

            writeAMF3IntegerData(bytes.length << 1 | 0x01);
            write(bytes);
        }
    }