diff --git a/src/encode.c b/src/encode.c
index 87e03cb9eff9fa11b85cdd0fc42e90a78a392611..b01c27e2884fe28e87eca03974569b020a656b7b 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -23,7 +23,7 @@
 #include "stuff.h"
 #include "version.h"
 
-RCSID("$Id: encode.c,v 1.23 1998/05/16 08:23:44 hubbe Exp $");
+RCSID("$Id: encode.c,v 1.24 1998/10/11 18:17:26 marcus Exp $");
 
 #ifdef _AIX
 #include <net/nh.h>
@@ -123,10 +123,10 @@ static void code_entry(int type, INT32 num, struct encode_data *data)
 
   switch(t)
   {
-  case 3: addchar(num >> 24);
-  case 2: addchar(num >> 16);
-  case 1: addchar(num >> 8);
-  case 0: addchar(num);
+  case 3: addchar((num >> 24)&0xff);
+  case 2: addchar((num >> 16)&0xff);
+  case 1: addchar((num >> 8)&0xff);
+  case 0: addchar(num&0xff);
   }
 }
 
diff --git a/src/modules/MIME/mime.c b/src/modules/MIME/mime.c
index 032cbb6c74f4917053bb9fa53023889a0d96a54d..a5b80210c8ec017602ee9df591f7f45cea2973d0 100644
--- a/src/modules/MIME/mime.c
+++ b/src/modules/MIME/mime.c
@@ -1,5 +1,5 @@
 /*
- * $Id: mime.c,v 1.12 1998/07/04 16:57:33 grubba Exp $
+ * $Id: mime.c,v 1.13 1998/10/11 18:17:39 marcus Exp $
  *
  * RFC1521 functionality for Pike
  *
@@ -10,7 +10,7 @@
 
 #include "config.h"
 
-RCSID("$Id: mime.c,v 1.12 1998/07/04 16:57:33 grubba Exp $");
+RCSID("$Id: mime.c,v 1.13 1998/10/11 18:17:39 marcus Exp $");
 #include "stralloc.h"
 #include "pike_macros.h"
 #include "object.h"
@@ -155,9 +155,9 @@ static void f_decode_base64( INT32 args )
 	/* 6 more bits to put into d */
 	if((d=(d<<6)|base64rtab[*src-' '])>=0x1000000) {
 	  /* d now contains 24 valid bits.  Put them in the buffer */
-	  low_my_putchar( d>>16, &buf );
-	  low_my_putchar( d>>8, &buf );
-	  low_my_putchar( d, &buf );
+	  low_my_putchar( (d>>16)&0xff, &buf );
+	  low_my_putchar( (d>>8)&0xff, &buf );
+	  low_my_putchar( d&0xff, &buf );
 	  d=1;
 	}
       } else if (*src=='=') {
@@ -170,9 +170,9 @@ static void f_decode_base64( INT32 args )
     /* If data size not an even multiple of 3 bytes, output remaining data */
     switch(pads) {
     case 1:
-      low_my_putchar( d>>8, &buf );
+      low_my_putchar( (d>>8)&0xff, &buf );
     case 2:
-      low_my_putchar( d, &buf );
+      low_my_putchar( d&0xff, &buf );
     }
 
     /* Return result */
@@ -439,9 +439,9 @@ static void f_decode_uue( INT32 args )
 	d |= ((*src++-' ')&63)<<6;
 	d |= ((*src++-' ')&63);
 	/* Output it into the buffer */
-	low_my_putchar( d>>16, &buf );
-	low_my_putchar( d>>8, &buf );
-	low_my_putchar( d, &buf );
+	low_my_putchar( (d>>16)&0xff, &buf );
+	low_my_putchar( (d>>8)&0xff, &buf );
+	low_my_putchar( d&0xff, &buf );
       }
 
       /* If the line didn't contain an even multiple of 24 bits, remove