pyflakes: Fix legacy print and exception usage under Python 3

Fix print statements and legacy exception usage in examples.

https://bugzilla.gnome.org/show_bug.cgi?id=731042