anchor.diff:          (write-byte 24 o) ;bitcount, 24-bit BMP
           (write-byte 0 o)
           (write-sequence (make-array 24 :initial-element 0 :element-type 'unsigned-byte) o) ;the rest of header
  -        (loop for y fixnum from (1- h) downto 0
  -              for ypos fixnum = (* y 3 w) do
  -              (loop for x fixnum from ypos to (plus ypos (* (1- w) 3)) by 3 do
  -                    (write-byte (the unsigned-byte (svref rgb x)) o)
  -                    (write-byte (the unsigned-byte (svref rgb (1+ x))) o)
  -                    (write-byte (the unsigned-byte (svref rgb (plus 2 x))) o))
  -              (loop for i fixnum from 0 below compl do ;adjusting to double-word
  -                    (write-byte 0 o)))))))
  -
  +        (ecase number-components
  +          (1
  +           (loop :for y :from (1- h) :downto 0 :do
  +                 (loop :for x :from (1- w) :downto 0 :do
  +                       (let ((grey (svref rgb (+ x (* y w)))))
  +                         (write-byte grey o)
  +                         (write-byte grey o)
  +                         (write-byte grey o)))
  +                 (dotimes (i compl)
  +                   (write-byte 0 o))))
  +          (3
  +           (loop for y fixnum from (1- h) downto 0
  +                 for ypos fixnum = (* y 3 w) do
  +                 (loop for x fixnum from ypos to (plus ypos (* (1- w) 3)) by 3 do
  +                       (write-byte (the unsigned-byte (svref rgb x)) o)
  +                       (write-byte (the unsigned-byte (svref rgb (1+ x))) o)
  +                       (write-byte (the unsigned-byte (svref rgb (plus 2 x))) o))
  +                 (loop for i fixnum from 0 below compl do ;adjusting to double-word
  +                       (write-byte 0 o)))))))))
   
   
   ;;; Provides simple user interface for encoder: quality may vary 1 to 5 (decreasing)
  
positive.code: 
  ;;; Function that maps value into SSSS
  (defun csize (n)
      (declare #.*optimize* (type fixnum n val LSB MSB))
      (svref *csize* (plus n 1023)))
  
  ;;; zigzag ordering
  
negative.code: ;;; Encodes block using specified huffman tables, returns new pred (DC prediction value)
  ;;; and last code written to stream for padding
  (defun encode-block (block tables pred s)
    (declare #.*optimize* (type fixnum pred)
             (type (simple-vector *) block))
    (let* ((ehufsi-dc (first (first tables)))
           (ehufco-dc (second (first tables)))
  