read and write protocol buffer