Changed image allocation to size_of_elements_float instead of size_of_elements*double. Uses much less memory and seems to be okay.