diff --git a/beat/web/ui/widgets.py b/beat/web/ui/widgets.py
index bafd9139d4615442a19ac28696b2d441c63fb67b..79d05e5b851f840c58ecdab71a9b0a4e917582fd 100644
--- a/beat/web/ui/widgets.py
+++ b/beat/web/ui/widgets.py
@@ -346,6 +346,8 @@ class CodeMirrorFileWidget(CodeMirrorTextarea):
             contents = value
         elif hasattr(value, "read"):
             contents = value.read()
+            if type(contents) == bytes:
+                contents = contents.decode("utf-8")
         else:
             contents = ""
         return mark_safe(super().render(name, contents, attrs, renderer))  # nosec