Fix Python 3 compatibility of examples.

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