make code more compatible with python3

change `<>` comparison to `!=`
change `dict.has_key` to `key in dict`
change `==` comparison with `None`, `True`, `False` to `is`
change `type` comparison to `isinstance`
change `map` and `filter` to list-comprehension
change `if not KEY in` to `if KEY not in`
update old style classes and related doctests
update `except Exception as`
update old style exception raising
update print-function compatibility
update unicode literals
update argument names for __new__
fix unnecessary `for else`
fix some docstrings