Python3 compatibility

replacing print statement to sys.stdout.write with checking django variable settings.DEBUG