use encodebytes instead of encodestring (#2483)
Merge pull request #2484 from piotrbulinski/develop

Use encodebytes instead of encodestring. Fixes #2483, #2484.