Making es51922.py Python2 and Python3 compatible

The `for line in sys.stdin:` solution does not work
as I hoped it would on Python2. We have to call
readline() again and check if the response is an
empty string.

In addition we have to convert input to ASCII bytes in Python3.
On Python2 this only adds a check if the input could be encoded
in ASCII and keeps the str type.