Fix bytes handling on python3

Fixes #356