This is what you want to avoid. Just serialize the bytes into the oStream and then write the offset information afterwards.