diff --git a/java/com/tigervnc/rfb/PixelBuffer.java b/java/com/tigervnc/rfb/PixelBuffer.java
index 392987d..88b3a89 100644
--- a/java/com/tigervnc/rfb/PixelBuffer.java
+++ b/java/com/tigervnc/rfb/PixelBuffer.java
@@ -44,8 +44,9 @@
       int rmask = pf.redMax << pf.redShift;
       int gmask = pf.greenMax << pf.greenShift;
       int bmask = pf.blueMax << pf.blueShift;
-      cm = new DirectColorModel(8, rmask, gmask, bmask);
-      if (!pf.trueColour)
+      if (pf.trueColour)
+        cm = new DirectColorModel(8, rmask, gmask, bmask);
+      else
         cm = new IndexColorModel(8, 256, new byte[256], new byte[256], new byte[256]);
       break;
     case 16: 
diff --git a/java/com/tigervnc/vncviewer/BIPixelBuffer.java b/java/com/tigervnc/vncviewer/BIPixelBuffer.java
index 88c9396..6690c79 100644
--- a/java/com/tigervnc/vncviewer/BIPixelBuffer.java
+++ b/java/com/tigervnc/vncviewer/BIPixelBuffer.java
@@ -34,30 +34,33 @@
 
   public void setPF(PixelFormat pf) {
     super.setPF(pf);
+    createImage(width(), height());
   }
 
   public void updateColourMap() {
     cm = new IndexColorModel(8, nColours, reds, greens, blues);
+    createImage(width_, height_);
   }
   
   // resize() resizes the image, preserving the image data where possible.
   public void resize(int w, int h) {
-    if (w == width() && h == height()) return;
+    if (w == width() && h == height())
+      return;
 
     width_ = w;
     height_ = h;
-    GraphicsEnvironment ge =
-      GraphicsEnvironment.getLocalGraphicsEnvironment();
-    GraphicsDevice gd = ge.getDefaultScreenDevice();
-    GraphicsConfiguration gc = gd.getDefaultConfiguration();
-    image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
-    image.setAccelerationPriority(1);
-    image.createGraphics();
-    WritableRaster wr = image.getRaster();
-    SinglePixelPackedSampleModel sm =
-      (SinglePixelPackedSampleModel)image.getSampleModel();
-    DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
-    data = db.getData();
+    createImage(w, h);
+  }
+
+  private void createImage(int w, int h) {
+    if (w == 0 || h == 0) return;
+    WritableRaster wr;
+    if (cm instanceof IndexColorModel)
+      wr = ((IndexColorModel)cm).createCompatibleWritableRaster(w, h);
+    else
+      wr = ((DirectColorModel)cm).createCompatibleWritableRaster(w, h);
+    image = new BufferedImage(cm, wr, true, null);
+    db = wr.getDataBuffer();
   }
 
   public void fillRect(int x, int y, int w, int h, int pix) {
@@ -92,8 +95,13 @@
       clip = null;
       img.flush();
     } else {
-      for (int j = 0; j < h; j++)
-        System.arraycopy(pix, (w*j), data, width_ * (y + j) + x, w);
+      if (image.getSampleModel().getTransferType() == DataBuffer.TYPE_BYTE) {
+        byte[] bytes = new byte[((int[])pix).length];
+        for (int i = 0; i < bytes.length; i++)
+          bytes[i] = (byte)((int[])pix)[i];
+        pix = bytes;
+      }
+      image.getSampleModel().setDataElements(x, y, w, h, pix, db); 
     }
   }
 
@@ -126,6 +134,7 @@
   }
 
   BufferedImage image;
+  DataBuffer db;
   Rectangle clip;
 
   static LogWriter vlog = new LogWriter("BIPixelBuffer");
diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java
index 0ad6906..498b4c8 100644
--- a/java/com/tigervnc/vncviewer/CConn.java
+++ b/java/com/tigervnc/vncviewer/CConn.java
@@ -625,6 +625,7 @@
   	            (newFullColour ? "enabled" : "disabled"));
       fullColour = newFullColour;
       formatChange = true;
+      forceNonincremental = true;
     } 
   }
 
@@ -680,7 +681,7 @@
     if (forceNonincremental || !continuousUpdates) {
       pendingUpdate = true;
       writer().writeFramebufferUpdateRequest(new Rect(0,0,cp.width,cp.height),
-                                                 !formatChange && !forceNonincremental);
+                                                 !forceNonincremental);
     }
 
     forceNonincremental = false;
@@ -921,8 +922,10 @@
 
   public void getOptions() {
     autoSelect = options.autoSelect.isSelected();
-    if (fullColour != options.fullColour.isSelected())
+    if (fullColour != options.fullColour.isSelected()) {
       formatChange = true;
+      forceNonincremental = true;
+    }
     fullColour = options.fullColour.isSelected();
     if (!fullColour) {
       int newLowColourLevel = (options.veryLowColour.isSelected() ? 0 :
@@ -930,6 +933,7 @@
       if (newLowColourLevel != lowColourLevel) {
         lowColourLevel = newLowColourLevel;
         formatChange = true;
+        forceNonincremental = true;
       }
     }
     int newEncoding = (options.zrle.isSelected() ?  Encodings.encodingZRLE :
