Fix TLV serialization to work with large types.