Altered read_image to pass the struct by reference rather than value.