refactor ImageIO, fix leaving tempfiles behind