Fix dictionary compatibility issues

In python3, there is no has_keys() method for dicts anymore. Instead use
the syntax

    "key" in mydict

which is compatible to python2.
Fix binary issues

In python3 byte-arrays and strings are not implicit convertible anymore.
Use .lower() as method instead of statically

str.lower() is not compatible for unicode and normal strings on python2.