Fix remaining Python-3 issues

While retaining Python-2 compatibility.