master: Remove copy-pasted code for storing metadata

There were three occurrences of procedure storing metadata
into disk file provided the files's descriptor to write to.
The procedure writes header and then the metadata body.

Change-Id: I5a8d4d556c41e2a3e3cd895b325cd52f739f0574