added imaging,  optimized memory consumption

added imaging,  optimized memory consumption,
fixed few bugs with memory localization, global variables, automatic
input of array/image dimensions during reading, etc