add transferBytes methods to reduce the amount of bytebuffer creation and copying
change transferBytes to copyToByteBuffer to make method intention clearler