Additional fixes for Python 3 compatibility.
Updates tests and samples in "demo" directory to work with Python 3.