import codecs


def from_bytes(val):
    """
    Translates value into valid utf8 string
    :param val: A value to translate
    :return: A valid utf8 string
    """
    try:
        return codecs.decode(val, 'utf8')
    except (UnicodeEncodeError, TypeError):
        return val