diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c
index 407f0d0f2..9987932eb 100644
--- a/modules/src/em_code/em.c
+++ b/modules/src/em_code/em.c
@@ -104,7 +104,10 @@ int C_open(char* nm)
 	*/
 
 	if (nm == 0)
+	{
 		C_ofp = STDOUT;	/* standard output	*/
+		sys_setbinarymode(stdout);
+	}
 	else
 	{
 
diff --git a/modules/src/read_em/read_em.c b/modules/src/read_em/read_em.c
index 4764d6951..7a3556fd0 100644
--- a/modules/src/read_em/read_em.c
+++ b/modules/src/read_em/read_em.c
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <assert.h>
 #include "alloc.h"
+#include "system.h"
 #include "em_label.h"
 #include "em_arith.h"
 #include "em_pseu.h"
@@ -136,7 +137,10 @@ EXPORT int EM_open(char *filename)
 		}
 	}
 	else
+	{
 		fd = stdin;
+		sys_setbinarymode(stdin);
+	}
 	EM_filename = filename;
 	init_input();
 
diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c
index 98ef2a44a..083fdf2f5 100644
--- a/util/amisc/aelflod.c
+++ b/util/amisc/aelflod.c
@@ -691,14 +691,14 @@ int main(int argc, char* argv[])
 			break;
 			
 		case 3: /* Both input and output files specified. */
-			output = fopen(argv[2], "w");
+			output = fopen(argv[2], "wb");
 			if (!output)
 				fatal("unable to open output file.");
 			outputfile = argv[2];
 			/* fall through */
 			
 		case 2: /* Input file specified. */
-			input = fopen(argv[1], "r");
+			input = fopen(argv[1], "rb");
 			if (!input)
 				fatal("unable to open input file.");
 			break;
diff --git a/util/amisc/aslod.c b/util/amisc/aslod.c
index cfccaec28..6fb115bf9 100644
--- a/util/amisc/aslod.c
+++ b/util/amisc/aslod.c
@@ -228,7 +228,7 @@ int main(int argc, char* argv[])
 			/* fall through */
 			
 		case 2: /* Input file specified. */
-			input = fopen(argv[1], "r");
+			input = fopen(argv[1], "rb");
 			if (!input)
 				fatal("unable to open input file.");
 			break;