Fix template unicode process for out.write