Fix to improve Python 3 compatibility (see Issue #1493).