         dsb (.asShortBuffer dbb)]
     {:rwChannel rwChannel :byte-buf dbb :short-buf dsb}))
         
-(defn write-header [mmap]
-  (.put (:byte-buf mmap) (create-header)))
+(defn write-seq [mmap byte-vals]
+  (.put (:byte-buf mmap) (byte-array (map byte byte-vals))))  
 
-;(defn write-image [pix w h bits-per-pixel pixel-size-um final-image?]
-  
+(defn write-bytes [mmap bytes]
+  (.put (:byte-buf mmap) bytes))
+
+(defn get-pos [mmap]
+  (.position (:byte-buf mmap)))
+
+(defn close-mmap [mmap]
+  (let [chan (:rwChannel mmap)]
+    (doto chan
+      (.truncate (get-pos mmap))
+      .close)))
 
 ; (.position dbb) <-- gets cursor pos
 ; (.position dbb 10) <-- sets cursor pos
-; (.put dbb (byte-array (map byte (range 10)))) 
-; (def q (byte-array 10))
 ; (.get dbb q) <-- read array
-; (.position dsb (bit-shift-right (.position dbb) 1))
-
 
 ;; testing
-
 
 ;;;; image generation
 

(defn create-header
  "Creates a big-endian tiff image file header."
  []
  (byte-array (map byte [77 77 0 42 0 0 0 8])))

(defn make-bytes [val n]
  (reverse
    (map #(bit-and 0xFF %)
         (take n (iterate #(bit-shift-right % 8) val)))))

(def tag-codes
  {


(def type-codes {:byte 1, :ascii 2, :short 3, :long 4, :rational 5})

(def type-length {:byte 1, :ascii 1, :short 2, :long 4, :rational 8})

(defn make-tag
  "Create a big-endian tiff image IFD entry"
  [tag type count value]
  (let [tag-code (tag tag-codes)
        type-code (type type-codes)
        type-length (type type-length)]
    (concat
      (make-bytes tag-code 2)
      (make-bytes type-code 2)
      (make-bytes count 4)
      (make-bytes value type-length)
      (make-bytes 0 (- 4 type-length)))))

(defn rational-value [x]
  (apply concat
