Added close method to PImage

Now it is possible to close the image file descriptor after using it, this avoid memory leak. Closes #2311