fixed ByteBuffer management

this should be (.position 0) to ensure the buffer is at the beginning