Thread safety fix on ImageIO calls