Add blank lines for legibility.

These lines mark some logical sections of the file and it is good to have
such sections both visually and mentally separate.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
Separate imports by origin.

We follow PEP-8 here and put all the standard library imports together,
separated from (and followed by) the 3rd party modules.

There is more work along these lines to deal with Python 2/3
compatibility.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
cosmetic: Python doesn't need boolean conditions enclosed by parens.

This makes the code less cluttered: "all things being equal, fewer pixels
make for easier reading".

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>