     fail _              = NoData
 
 instance Storable a => Storable (Value a) where
-  sizeOf _ = sizeOf (undefined :: Bool) + sizeOf (undefined :: a)
-  alignment _ = 4
+  sizeOf _ = sizeOf (undefined :: a) + sizeOf (undefined :: Word8)
+  alignment _ = alignment (undefined :: a)
 
   {-# INLINE peek #-}
   peek p = do
-            let p1 = (castPtr p::Ptr Bool) `plusPtr` 1
-            t <- peek (castPtr p::Ptr Bool)
-            if t
+            let p1 = (castPtr p::Ptr Word8) `plusPtr` 1
+            t <- peek (castPtr p::Ptr Word8)
+            if t/=0
               then fmap Value (peekElemOff (castPtr p1 :: Ptr a) 0)
               else return NoData
 
   {-# INLINE poke #-}
   poke p x = case x of
-    NoData -> poke (castPtr p :: Ptr Bool) False
+    NoData -> poke (castPtr p :: Ptr Word8) 0
     Value a -> do
-        poke (castPtr p :: Ptr Bool) True
-        let p1 = (castPtr p :: Ptr Bool) `plusPtr` 1
+        poke (castPtr p :: Ptr Word8) 1
+        let p1 = (castPtr p :: Ptr Word8) `plusPtr` 1
         pokeElemOff (castPtr p1) 0 a
 
 isNoData :: Value a -> Bool

  => Band s t a -> Int -> Int -> GDAL s (Vector (Value a))
readBandBlock band x y = do
  len <- bandBlockLen band
  liftIO $ readMasked band $ \b -> do
    f <- mallocForeignPtrArray len
    withForeignPtr f $ \ptr ->
      throwIfError "could not read block" $
        readBlock_ b (fromIntegral x) (fromIntegral y) (castPtr ptr)
    return $ St.unsafeFromForeignPtr0 f len
{-# INLINE readBandBlock #-}

foreign import ccall safe "gdal.h GDALReadBlock" readBlock_

  => RWBand s a -> Int -> Int -> Vector (Value a) -> GDAL s ()
writeBandBlock b x y uvec = do
  nElems <- bandBlockLen b
  bNodata <- liftIO $ fmap (maybe nodata fromNodata) (c_bandNodataValue b)
  liftIO $ do
    let (fp, len) = St.unsafeToForeignPtr0 vec
        vec = St.map (fromValue bNodata) uvec
