Add Python 3 support

Rewrite print() call to support Python 3 syntax.

Don't import exceptions for Python 3.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>