finished writing the load image function.