Memory usage

improve memory allocation, account for special cases (like all black images), debug reconstruction of images from transform data.