Fix Python 3 compatibility of examples.

This commit adds Python 3 compatibility to the examples without breaking Python 2 support (actually, I only had to change `print` statements).