Implement serialization to buffers