<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def deflate_and_base64_encode(string_val):
 """ Deflates and the base64 encodes a string :param string_val: The string to deflate and encode :return: The deflated and encoded string """

    if not isinstance(string_val, six.binary_type):
        string_val = string_val.encode('utf-8')
    return base64.b64encode(zlib.compress(string_val)[2:-4])