common: Reorganize code serializing vectors

LizardFS does send vector length when serializing it, MooseFS does
not. This patch provides code needed to do both types of serialization.