diff --git a/IPython/html/nbconvert/tests/test_nbconvert_handlers.py b/IPython/html/nbconvert/tests/test_nbconvert_handlers.py
index 657c6d9..16e44fe 100644
--- a/IPython/html/nbconvert/tests/test_nbconvert_handlers.py
+++ b/IPython/html/nbconvert/tests/test_nbconvert_handlers.py
@@ -1,4 +1,5 @@
 # coding: utf-8
+import base64
 import io
 import json
 import os
@@ -37,6 +38,10 @@ class NbconvertAPI(object):
     def list_formats(self):
         return self._req('GET', '')
 
+png_green_pixel = base64.encodestring(b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00'
+b'\x00\x00\x01\x00\x00x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDAT'
+b'\x08\xd7c\x90\xfb\xcf\x00\x00\x02\\\x01\x1e.~d\x87\x00\x00\x00\x00IEND\xaeB`\x82')
+
 class APITest(NotebookTestBase):
     def setUp(self):
         nbdir = self.notebook_dir.name
@@ -51,6 +56,7 @@ class APITest(NotebookTestBase):
         ws.cells.append(new_heading_cell(u'Created by test ³'))
         cc1 = new_code_cell(input=u'print(2*6)')
         cc1.outputs.append(new_output(output_text=u'12'))
+        cc1.outputs.append(new_output(output_png=png_green_pixel, output_type='pyout'))
         ws.cells.append(cc1)
         
         with io.open(pjoin(nbdir, 'foo', 'testnb.ipynb'), 'w',
diff --git a/IPython/nbconvert/preprocessors/extractoutput.py b/IPython/nbconvert/preprocessors/extractoutput.py
index 961fde0..6fc5fee 100755
--- a/IPython/nbconvert/preprocessors/extractoutput.py
+++ b/IPython/nbconvert/preprocessors/extractoutput.py
@@ -17,7 +17,7 @@ import base64
 import sys
 import os
 
-from IPython.utils.traitlets import Unicode
+from IPython.utils.traitlets import Unicode, Set
 from .base import Preprocessor
 from IPython.utils import py3compat
 
@@ -34,6 +34,7 @@ class ExtractOutputPreprocessor(Preprocessor):
     output_filename_template = Unicode(
         "{unique_key}_{cell_index}_{index}.{extension}", config=True)
 
+    extract_output_types = Set({'png', 'jpg', 'svg', 'pdf'}, config=True)
 
     def preprocess_cell(self, cell, resources, cell_index):
         """
@@ -63,8 +64,8 @@ class ExtractOutputPreprocessor(Preprocessor):
         #Loop through all of the outputs in the cell
         for index, out in enumerate(cell.get('outputs', [])):
 
-            #Get the output in data formats that the template is interested in.
-            for out_type in self.display_data_priority:
+            #Get the output in data formats that the template needs extracted
+            for out_type in self.extract_output_types:
                 if out.hasattr(out_type): 
                     data = out[out_type]
 
diff --git a/IPython/nbconvert/templates/python.tpl b/IPython/nbconvert/templates/python.tpl
index c863da7..8aa456b 100644
--- a/IPython/nbconvert/templates/python.tpl
+++ b/IPython/nbconvert/templates/python.tpl
@@ -27,7 +27,7 @@ it introduces a new line
 {# .... #}
 
 {% block pyout %}
-{{ output.text | indent | comment_lines }}
+{{ output.text or '' | indent | comment_lines }}
 {% endblock pyout %}
 
 {% block stream %}
@@ -48,4 +48,4 @@ it introduces a new line
 
 {% block unknowncell scoped %}
 unknown type  {{ cell.type }}
-{% endblock unknowncell %}
\ No newline at end of file
+{% endblock unknowncell %}