<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def dump_blob(elem, elem_type=None):
 """ Dumps blob message. Supports both blob and raw value. :param writer: :param elem: :param elem_type: :param params: :return: """

    elem_is_blob = isinstance(elem, x.BlobType)
    data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem
    if data is None or len(data) == 0:
        return b''
    if isinstance(data, (bytes, bytearray, list)):
        return base64.b16encode(bytes(data))
    else:
        raise ValueError('Unknown blob type')