 plug-ins/common/file-tiff-load.c |   35 ++++++++++++++++++++++++++++++
 plug-ins/common/file-tiff-save.c |   44 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/plug-ins/common/file-tiff-load.c b/plug-ins/common/file-tiff-load.c
index ea93fe2..3485165 100644
--- a/plug-ins/common/file-tiff-load.c
+++ b/plug-ins/common/file-tiff-load.c
@@ -56,6 +56,7 @@
 
 #include <glib/gstdio.h>
 #ifdef G_OS_WIN32
+#include <windows.h>
 #include <libgimpbase/gimpwin32-io.h>
 #endif
 
@@ -263,6 +264,10 @@ run (const gchar      *name,
   GError            *error  = NULL;
   gint32             image;
   TiffSelectedPages  pages;
+#ifdef G_OS_WIN32
+  gint               winclen;
+  thandle_t          filedescriptor;
+#endif
 
   run_mode = param[0].data.d_int32;
 
@@ -283,7 +288,37 @@ run (const gchar      *name,
       TIFF        *tif      = NULL;
       gint         fd;
 
+#ifdef G_OS_WIN32
+      winclen = MultiByteToWideChar (CP_UTF8, 0, filename, -1, NULL, 0);
+      if (winclen >= 0)
+        {
+          wchar_t wname[winclen];
+
+          winclen = MultiByteToWideChar(CP_UTF8, 0, filename, -1, wname, winclen);
+
+          filedescriptor = (thandle_t)CreateFileW (wname,
+                                                   GENERIC_READ,
+                                                   FILE_SHARE_READ,
+                                                   NULL,
+                                                   OPEN_EXISTING,
+                                                   FILE_ATTRIBUTE_NORMAL,
+                                                   NULL);
+          if (filedescriptor == INVALID_HANDLE_VALUE)
+            {
+              fd = -1;
+            }
+          else
+            {
+              fd = (gint)filedescriptor;
+            }
+        }
+      else
+        {
+          fd = -1;
+        }
+#else
       fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
+#endif
 
       if (fd == -1)
         {
diff --git a/plug-ins/common/file-tiff-save.c b/plug-ins/common/file-tiff-save.c
index c3af7de..3ca0e0f 100644
--- a/plug-ins/common/file-tiff-save.c
+++ b/plug-ins/common/file-tiff-save.c
@@ -56,6 +56,7 @@
 
 #include <glib/gstdio.h>
 #ifdef G_OS_WIN32
+#include <windows.h>
 #include <libgimpbase/gimpwin32-io.h>
 #endif
 
@@ -662,6 +663,11 @@ save_image (const gchar  *filename,
   gboolean       invert   = TRUE;
   const guchar   bw_map[] = { 0, 0, 0, 255, 255, 255 };
   const guchar   wb_map[] = { 255, 255, 255, 0, 0, 0 };
+#ifdef G_OS_WIN32
+  gint               winclen;
+  thandle_t          filedescriptor;
+  DWORD              createflag;
+#endif
 
   compression = tsvals.compression;
 
@@ -676,7 +682,45 @@ save_image (const gchar  *filename,
   tile_height = gimp_tile_height ();
   rowsperstrip = tile_height;
 
+  #ifdef G_OS_WIN32
+      if (g_file_test (filename, G_FILE_TEST_EXISTS))
+        {
+          createflag = TRUNCATE_EXISTING;
+        }
+      else
+        {
+          createflag = CREATE_NEW;
+        }
+
+      winclen = MultiByteToWideChar (CP_UTF8, 0, filename, -1, NULL, 0);
+      if (winclen >= 0)
+        {
+          wchar_t wname[winclen];
+
+          winclen = MultiByteToWideChar(CP_UTF8, 0, filename, -1, wname, winclen);
+          filedescriptor = (thandle_t)CreateFileW (wname,
+                                                   GENERIC_WRITE,
+                                                   0,
+                                                   NULL,
+                                                   createflag,
+                                                   FILE_ATTRIBUTE_NORMAL,
+                                                   NULL);
+          if (filedescriptor == INVALID_HANDLE_VALUE)
+            {
+              fd = -1;
+            }
+          else
+            {
+              fd = (gint)filedescriptor;
+            }
+        }
+      else
+        {
+          fd = -1;
+        }
+#else
   fd = g_open (filename, O_CREAT | O_TRUNC | O_WRONLY | _O_BINARY, 0666);
+#endif
 
   if (fd == -1)
     {
