<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def portable_b64encode(thing):
 """Wrap b64encode for Python 2 & 3"""

    if is_py3():
        try:
            some_bits = bytes(thing, 'utf-8')
        except TypeError:
            some_bits = thing

        return polite_string(b64encode(some_bits).decode('utf-8'))

    return polite_string(b64encode(thing))