@classmethod
def encode(cls, entry):
    """
        Classmethod that applies conditional encoding based on
        mime-type. Given an entry as returned by __call__ return the
        data in the appropriate encoding.
        """
    data, info = entry
    if info['mime_type'] in cls.utf8_mime_types:
        return data.encode('utf-8')
    else:
        return data
