def ensure_bytes(obj):
    """
    Converts to bytes
    :param obj: Str or Bytes (or anything else) to convert to bytes representation
    """
    if obj is None:
        raise ValueError('Cannot byteify None')
    if isinstance(obj, bytes):
        return obj
    if isinstance(obj, str):
        return obj.encode('utf-8')
    return str(obj).encode('utf-8')
