def _bencode_bytes(value, encoding='utf-8'):
    """ Encode a bytestring (strings as UTF-8), eg 'hello' -> 5:hello """
    if isinstance(value, str):
        value = value.encode(encoding)
    return str(len(value)).encode(encoding) + b':' + value