'Gzip the file contents, base64 encode it, return as string.
:param filename: The filename that holds the bytes to encode
:return: Encoded data which can be decoded using decode_b64_data, this
output is usually stored in a profile.'

def encode_b64_data(self, filename):

    data = base64.b64encode(file(filename).read().encode('zlib')).strip()
    return ('%s%s' % (self.DATA_PROTO, data))
