Fix base64 encoding on bytes issue in Py3

No immediate regression visible on Py2
Fixes #2553