Fix chatdemo to work with Python 3.x

Fix a bug in the chat demo, so that it works with python 3.x (xrange is now range).