Add protobuf serialization

TODO make protobuf serialization optional