encode string as bytes for python3 support