implement protobuf serialization