Make `write_u16_len_prefixed_data` generic over the type of output