Index: trunk/src/org/openstreetmap/josm/data/cache/BufferedImageCacheEntry.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/cache/BufferedImageCacheEntry.java	(revision 17362)
+++ trunk/src/org/openstreetmap/josm/data/cache/BufferedImageCacheEntry.java	(revision 17363)
@@ -4,5 +4,7 @@
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 
 import javax.imageio.ImageIO;
@@ -28,4 +30,19 @@
     public BufferedImageCacheEntry(byte[] content) {
         super(content);
+    }
+
+    /**
+     * Encodes the given image as PNG and returns a cache entry
+     * @param img the image
+     * @return a cache entry for the PNG encoded image
+     * @throws UncheckedIOException if an I/O error occurs
+     */
+    public static BufferedImageCacheEntry pngEncoded(BufferedImage img) {
+        try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
+            ImageIO.write(img, "png", output);
+            return new BufferedImageCacheEntry(output.toByteArray());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java	(revision 17362)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java	(revision 17363)
@@ -9,11 +9,9 @@
 import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.util.ArrayList;
 import java.util.Collection;
-
-import javax.imageio.ImageIO;
 
 import org.apache.commons.jcs3.access.behavior.ICacheAccess;
@@ -165,8 +163,7 @@
 
         if (!cacheOff && cache != null) {
-            try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
-                ImageIO.write(scaledBI, "png", output);
-                cache.put(cacheIdent, new BufferedImageCacheEntry(output.toByteArray()));
-            } catch (IOException e) {
+            try {
+                cache.put(cacheIdent, BufferedImageCacheEntry.pngEncoded(scaledBI));
+            } catch (UncheckedIOException e) {
                 Logging.warn("Failed to save geoimage thumb to cache");
                 Logging.warn(e);
