fix photos out of memory bug