Fixed bug where images didn't get saved correctly