I upgraded from Python 2.7 to 3.6 and I broke my ability to ... - reddit
If it's your own code, fix it: as_string () (or str (message)) returns text, while as_bytes () (or bytes (message)) returns bytes, and in Python 3 base64 is a bytes->bytes encoding, so it needs to be fed bytes. If it's a third-party library: it's not Python3-compatible, migrate to something else or rollback to Python 2. 1