add {read,write}_buf functions. closes #15