diff --git a/PIL/Image.py b/PIL/Image.py
--- a/PIL/Image.py
+++ b/PIL/Image.py
@@ -1715,7 +1715,10 @@ def save(self, fp, format=None, **params):
         if not format:
             if ext not in EXTENSION:
                 init()
-            format = EXTENSION[ext]
+            try:
+                format = EXTENSION[ext]
+            except KeyError:
+                raise ValueError('unknown file extension: {}'.format(ext))
 
         if format.upper() not in SAVE:
             init()

diff --git a/Tests/test_image.py b/Tests/test_image.py
--- a/Tests/test_image.py
+++ b/Tests/test_image.py
@@ -87,6 +87,11 @@ def test_tempfile(self):
             reloaded = Image.open(fp)
             self.assert_image_similar(im, reloaded, 20)
 
+    def test_unknown_extension(self):
+        im = hopper()
+        temp_file = self.tempfile("temp.unknown")
+        self.assertRaises(ValueError, lambda: im.save(temp_file))
+
     def test_internals(self):
 
         im = Image.new("L", (100, 100))

cryptic error message when saving to a file without a valid extension
### What did you do?
I tried to save a file with an invalid extension, e. g. ".5"

### What did you expect to happen?
I would expect getting an error message telling me that pillow doesn't know this extension.

### What actually happened?
I got a somewhat cryptic error message:

      File "/usr/local/lib/python3.5/dist-packages/PIL/Image.py", line 1683, in save
        format = EXTENSION[ext]
    KeyError: '.5'`

### What versions of Pillow and Python are you using?
Python 3.5.2 with pillow 3.4.2

```
from PIL import Image
im = Image.open('test.jpg')
im.save('2.5') # error
```

I think this could be easily fixed by adding a `try`/`except` block around line 1718 in Image.py (line number corresponds to the version on github) that re-raises the exception with a clear error message.


