Add APIs for reading and writing bytes

Implemented issue #2.