fixed possible nullpointer + limited max difference in image_buffer