def to_bytes(value):
    """Get a byte array representing the value"""
    if isinstance(value, unicode):
        return value.encode('utf8')
    elif not isinstance(value, str):
        return str(value)
    return value