Index: /trunk/source/lisp-kernel/image.c
===================================================================
--- /trunk/source/lisp-kernel/image.c	(revision 12810)
+++ /trunk/source/lisp-kernel/image.c	(revision 12811)
@@ -26,4 +26,5 @@
 #endif
 #include <stdio.h>
+#include <limits.h>
 
 
@@ -175,5 +176,5 @@
   off_t
     pos = seek_to_next_page(fd), advance;
-  int 
+  natural
     mem_size = sect->memory_size;
   void *addr;
@@ -379,13 +380,18 @@
 writebuf(int fd, char *bytes, natural n)
 {
-  natural remain = n;
-  int result;
+  natural remain = n, this_size;
+  signed_natural result;
 
   while (remain) {
-    result = write(fd, bytes, remain);
+    this_size = remain;
+    if (this_size > INT_MAX) {
+      this_size = INT_MAX;
+    }
+    result = write(fd, bytes, this_size);
     if (result < 0) {
       return errno;
     }
     bytes += result;
+
     remain -= result;
   }
