diff --git a/tests/audiogen.c b/tests/audiogen.c
index 4913a6ced864201198d14f77a78dc4fdcb07860a..b026a713a6ba7780e0c7d32acf3c289646608599 100644
--- a/tests/audiogen.c
+++ b/tests/audiogen.c
@@ -94,7 +94,7 @@ int main(int argc, char **argv)
         exit(1);
     }
     
-    outfile = fopen(argv[1], "w");
+    outfile = fopen(argv[1], "wb");
     if (!outfile) {
         perror(argv[1]);
         return 1;
diff --git a/tests/videogen.c b/tests/videogen.c
index 5f4ae3c0fa64850ef1012743abbbd62db0e22499..0a7924301bac946d63b014a564bbf72064d0b6ad 100644
--- a/tests/videogen.c
+++ b/tests/videogen.c
@@ -92,7 +92,7 @@ void pgmyuv_save(const char *filename, int w, int h,
 
     rgb24_to_yuv420p(lum_tab, cb_tab, cr_tab, rgb_tab, w, h);
 
-    f = fopen(filename,"w");
+    f = fopen(filename,"wb");
     fprintf(f, "P5\n%d %d\n%d\n", w, (h * 3) / 2, 255);
     fwrite(lum_tab, 1, w * h, f);
     h2 = h / 2;