    (let [image (core popNextTaggedImage)]
      (println "Start saving procedure...")
        (save-images-fast image n)))
+
+(defn image-to-byte-buffer [pix]
+  (let [buffer (.. ByteBuffer
+                         (allocate (* (count pix) 2))
+                         (order ByteOrder/BIG_ENDIAN))]
+    (.. buffer asShortBuffer (put pix))))
+
+(defn byte-buffer-test [n]
+  (let [img (core getImage)]
+    (time
+      (dorun
+        (repeatedly n #(image-to-byte-buffer img))))))
  
   
 

           (org.json JSONArray JSONObject)
           (org.micromanager MMStudioMainFrame)
           (org.micromanager.api DataProcessor)
           (org.micromanager.acquisition TaggedImageStorageMultipageTiff))
  (:require [org.micromanager.mm :as mm])
  (:use [org.micromanager.mm :only (edt load-mm core gui mmc)]))

  (let [tags (.tags image)
        summary (image-test-summary "test1" 1)
        storage (TaggedImageStorageMultipageTiff.
                  "G:/acquisitions/" true summary false true)]
    (doto tags
      (.put "Slice" 0)
      (.put "ChannelIndex" 0)
      (.put "PositionIndex" 0)
      (.put "PixelType" "GRAY16"))
    (time
      (dotimes [i n]
        (.put tags "Frame" i)
        (.putImage storage image)
        ))
    (doto storage .finished .close)))
 
 (defn fast-image-saving-test [n]
