modified the library, tests and applications to support both Python3 and Python2