Update image buffer handling code (not yet complete).