To Python 3

And some error handling.
Fix on last commit
Merge pull request #1 from mafagafo/master

To Python 3