diff --git a/salt/_compat.py b/salt/_compat.py
index <HASH>..<HASH> 100644
--- a/salt/_compat.py
+++ b/salt/_compat.py
@@ -177,8 +177,19 @@ else:
 
 if PY3:
     from io import StringIO
+    from io import BytesIO as cStringIO
 else:
     from StringIO import StringIO
+    from cStringIO import StringIO as cStringIO
+
+def string_io(data=None):  # cStringIO can't handle unicode
+    '''
+    Pass data through to stringIO module and return result
+    '''
+    try:
+        return cStringIO(bytes(data))
+    except (UnicodeEncodeError, TypeError):
+        return StringIO(data)
 
 if PY3:
     import queue as Queue
add more stringio support to compat