don't you need to close the image after? to avoid leaking file descriptors?