  using std::max;
  using std::sort;
 diff --git a/OpenEXR/IlmImf/ImfStdIO.cpp b/OpenEXR/IlmImf/ImfStdIO.cpp
-index 1839a94..7828bc0 100644
+index 1839a94..95c7d9f 100644
 --- a/OpenEXR/IlmImf/ImfStdIO.cpp
 +++ b/OpenEXR/IlmImf/ImfStdIO.cpp
-@@ -43,14 +43,28 @@
+@@ -43,12 +43,32 @@
  #include <ImfStdIO.h>
  #include "Iex.h"
  #include <errno.h>

+
+
+#endif // INCLUDED_IMF_FSTREAM_MINGW_H
diff --git a/OpenEXR/IlmImfTest/testExistingStreams.cpp b/OpenEXR/IlmImfTest/testExistingStreams.cpp
index 69658c3..8025a40 100644
--- a/OpenEXR/IlmImfTest/testExistingStreams.cpp
+++ b/OpenEXR/IlmImfTest/testExistingStreams.cpp
@@ -136,7 +136,7 @@ MMIFStream::MMIFStream (const char fileName[]):
     _length (0),
     _pos (0)
 {
-    std::ifstream ifs (fileName, ios_base::binary);
+    OPENEXR_IMF_INTERNAL_NAMESPACE::ifstream ifs (fileName, ios_base::binary);
 
     //
     // Get length of file
@@ -227,7 +227,7 @@ writeReadScanLines (const char fileName[],
     {
         cout << "writing";
 	remove (fileName);
-	std::ofstream os (fileName, ios_base::binary);
+	OPENEXR_IMF_INTERNAL_NAMESPACE::ofstream os (fileName, ios_base::binary);
 	StdOFStream ofs (os, fileName);
 	RgbaOutputFile out (ofs, header, WRITE_RGBA);
 	out.setFrameBuffer (&p1[0][0], 1, width);
@@ -236,7 +236,7 @@ writeReadScanLines (const char fileName[],
 
     {
         cout << ", reading";
-	std::ifstream is (fileName, ios_base::binary);
+	OPENEXR_IMF_INTERNAL_NAMESPACE::ifstream is (fileName, ios_base::binary);
 	StdIFStream ifs (is, fileName);
 	RgbaInputFile in (ifs);
 
@@ -330,7 +330,7 @@ writeReadMultiPart (const char fileName[],
     {
         cout << "writing";
         remove (fileName);
-        std::ofstream os (fileName, ios_base::binary);
+        OPENEXR_IMF_INTERNAL_NAMESPACE::ofstream os (fileName, ios_base::binary);
         StdOFStream ofs (os, fileName);
         MultiPartOutputFile out (ofs, &headers[0],2);
         FrameBuffer f;
@@ -349,7 +349,7 @@ writeReadMultiPart (const char fileName[],
                         
     {
         cout << ", reading";
-        std::ifstream is (fileName, ios_base::binary);
+        OPENEXR_IMF_INTERNAL_NAMESPACE::ifstream is (fileName, ios_base::binary);
         StdIFStream ifs (is, fileName);
         MultiPartInputFile in (ifs);
         
@@ -462,7 +462,7 @@ writeReadTiles (const char fileName[],
     {
         cout << "writing";
 	remove (fileName);
-	std::ofstream os (fileName, ios_base::binary);
+	OPENEXR_IMF_INTERNAL_NAMESPACE::ofstream os (fileName, ios_base::binary);
 	StdOFStream ofs (os, fileName);
 	TiledRgbaOutputFile out (ofs, header, WRITE_RGBA, 20, 20, ONE_LEVEL);
 	out.setFrameBuffer (&p1[0][0], 1, width);
@@ -471,7 +471,7 @@ writeReadTiles (const char fileName[],
 
     {
         cout << ", reading";
-	std::ifstream is (fileName, ios_base::binary);
+	OPENEXR_IMF_INTERNAL_NAMESPACE::ifstream is (fileName, ios_base::binary);
 	StdIFStream ifs (is, fileName);
 	TiledRgbaInputFile in (ifs);
 

+typedef std::ofstream ofstream;
+#endif //FSTREAM_USE_STDIO_FILEBUF
+
+#ifdef _WIN32
+namespace StrUtils {
+//-------------------------------------------
+// Converts a UTF-8 encoded string into a UTF-16 encoded wide string.
+// This is useful on Windows to correctly handle UTF-8 encoded std::string filenames 
+// passed to ifstream/ofstream
+//-------------------------------------------
+IMF_EXPORT std::wstring utf8_to_utf16 (const std::string& str);
+
+} // namespace StrUtils
+#endif // _WIN32
+
 //-------------------------------------------
 // class StdIFStream -- an implementation of
 // class OPENEXR_IMF_INTERNAL_NAMESPACE::IStream based on class std::ifstream
@@ -76,7 +105,7 @@ class IMF_EXPORT StdIFStream: public OPENEXR_IMF_INTERNAL_NAMESPACE::IStream
     // will not close the std::ifstream.
     //---------------------------------------------------------
 
