add mode argument to ndimage.imread and use context manager