support py3k

and refine coding style based on PEP8
fixed 2 failed tests
add travis ci.