Bug 975550 Handle python 2.6 when preventing invalid utf-8 being writting to test files. r=ted,a=test-only

--HG--
extra : transplant_source : q%89O%DE%E8%E0U%3A%EA%A1%FC%FEw%A3%FD%D95%09%9E%15