Python 3 compatibility fix

This should work from Python 2.6, which is required by Django 1.5 anyway.