diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py
index 2948f8579..00e749f8b 100644
--- a/gramps/plugins/webreport/narrativeweb.py
+++ b/gramps/plugins/webreport/narrativeweb.py
@@ -4588,7 +4588,7 @@ class MediaPages(BasePage):
                                     os.close(filed)
                                     self.report.archive.add(dest, initial_image_path)
                                 else:
-                                    filed = open(os.path.join(self.html_dir, initial_image_path), 'w')
+                                    filed = open(os.path.join(self.html_dir, initial_image_path), 'wb')
                                     filed.write(initial_image_data)
                                     filed.close()
                             else: