I would use the following format when writing stuff to disk:

```
<size> (a uint32)
<protomsg>
```

size denotes the length of the following protobuf message that you then decode. So whenever you write sth out you write it with a size marker prepending the actual message.