Python3 support + small fixes and circular dependency resolving

*This is just a proposal, not an actual pull request, it should be refined and fixed.*

I added Python3 compatibility support using `six`. Few issues still remain:

1. Some circular imports still cause problems, so I added the imports into the function calls instead at the top of the module.
2. Some tests for Python3 fail (randomly) since the order of the `Attributes` is not the same. I have not yet digged deep enough to find out the cause of the error, but I suspect that the problem lies in different key ordering in Python2 and Python3 dictionary... (It seems to me that some tests rely on the key order in the dictionary)