General fixes

Hi.

Here are some general fixes for code quality. There is a lot more to do, but I will keep things simple for the moment and send only these commits right now.

BTW, the burden of maintaining two versions of the same script is huge and it would be better to merge the two scripts in only one that is compatible with Python 2 and Python 3 simultaneously.

For an example of how to do that, see how youtube-dl does this (especially the part about the `compat_` thing that is done in https://github.com/rg3/youtube-dl/blob/master/youtube_dl/utils.py).


Thanks,
Rogério Brito.