bpo-43651: Fix EncodingWarning in tests. (GH-25655)

* test_httplib
* test_httpservers
* test_logging
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index c3d7c8f..12574a6 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -541,7 +541,7 @@ def test_html_escape_filename(self):
         fullpath = os.path.join(self.tempdir, filename)
 
         try:
-            open(fullpath, 'w').close()
+            open(fullpath, 'wb').close()
         except OSError:
             raise unittest.SkipTest('Can not create file %s on current file '
                                     'system' % filename)
@@ -646,7 +646,7 @@ def setUp(self):
             self.skipTest("Python executable path is not encodable to utf-8")
 
         self.nocgi_path = os.path.join(self.parent_dir, 'nocgi.py')
-        with open(self.nocgi_path, 'w') as fp:
+        with open(self.nocgi_path, 'w', encoding='utf-8') as fp:
             fp.write(cgi_file1 % self.pythonexe)
         os.chmod(self.nocgi_path, 0o777)