diff --git a/src/rez/util.py b/src/rez/util.py
index <HASH>..<HASH> 100644
--- a/src/rez/util.py
+++ b/src/rez/util.py
@@ -46,9 +46,18 @@ class yaml_literal(str):
 
 
 def yaml_literal_presenter(dumper, data):
-    return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
-yaml.add_representer(yaml_literal, yaml_literal_presenter)
-
+    tag = None
+    try:
+        data = unicode(data, 'ascii')
+        tag = u'tag:yaml.org,2002:str'
+    except UnicodeDecodeError:
+        try:
+            data = unicode(data, 'utf-8')
+            tag = u'tag:yaml.org,2002:str'
+        except UnicodeDecodeError:
+            data = data.encode('base64')
+            tag = u'tag:yaml.org,2002:binary'
+    return dumper.represent_scalar(tag, data, '|')
 
 # TODO deprecate
 class Common(object):
Improving yaml_literal presenter. Allan's implementation