diff --git a/apitools/base/py/transfer.py b/apitools/base/py/transfer.py
index <HASH>..<HASH> 100644
--- a/apitools/base/py/transfer.py
+++ b/apitools/base/py/transfer.py
@@ -560,6 +560,9 @@ if six.PY3:
                 return
             self.write(msg._payload)
 
+        def _encode(self, s):
+            return s.encode('ascii', 'surrogateescape')
+
         # Default body handler
         _writeBody = _handle_text
Fix encoding issue with rfc<I> messages (#<I>)