Adding images is broken in python3 if the pptx already contains images

First of all thank you for the nice software!

I'm porting some code from python2 to python3. The code works in python2 and I've had to change very little (some divisions basically) but it kept breaking in py3. After quite a bit of trial and error I've determined that it works fine as long as there are NO images in the 'pptx-template'.

In python3 'part.partname.idx' is None for (all/any) images in the pptx template.

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
...
In [1]: from pptx import Presentation
In [2]: from pptx.util import Inches
In [3]: prs = Presentation("demo.pptx")
In [4]: slide = prs.slides[0]
In [5]: slide.shapes.add_picture("/tmp/laughing-smiley-face-clip-art-smiley-face-clip-art10.jpeg", Inches(2), Inches(2))
Out[5]: <pptx.shapes.picture.Picture at 0x7fea2de52350>

But:

Python 3.4.3 (default, Oct 14 2015, 20:28:29)
...
In [1]: from pptx import Presentation
In [2]: from pptx.util import Inches
In [3]: prs = Presentation("demo.pptx")
In [4]: slide = prs.slides[0]
In [5]: slide.shapes.add_picture("/tmp/laughing-smiley-face-clip-art-smiley-face-clip-art10.jpeg", Inches(2), Inches(2))


TypeError Traceback (most recent call last)
in ()
----> 1 slide.shapes.add_picture("/tmp/laughing-smiley-face-clip-art-smiley-face-clip-art10.jpeg", Inches(2), Inches(2))

/data/ve/ttatt/lib/python3.4/site-packages/pptx/shapes/shapetree.py in add_picture(self, image_file, left, top, width, height)
147 object.
148 """
--> 149 image_part, rId = self._slide.get_or_add_image_part(image_file)
150 pic = self._add_pic_from_image_part(
151 image_part, rId, left, top, width, height

/data/ve/ttatt/lib/python3.4/site-packages/pptx/parts/slide.py in get_or_add_image_part(self, image_file)
39 newly created.
40 """
---> 41 image_part = self._package.get_or_add_image_part(image_file)
42 rId = self.relate_to(image_part, RT.IMAGE)
43 return image_part, rId

/data/ve/ttatt/lib/python3.4/site-packages/pptx/package.py in get_or_add_image_part(self, image_file)
64 otherwise a new one is created.
65 """
---> 66 return self._image_parts.get_or_add_image_part(image_file)
67
68 def next_image_partname(self, ext):

/data/ve/ttatt/lib/python3.4/site-packages/pptx/package.py in get_or_add_image_part(self, image_file)
137 image_part = self._find_by_sha1(image.sha1)
138 if image_part is None:
--> 139 image_part = ImagePart.new(self._package, image)
140 return image_part
141

/data/ve/ttatt/lib/python3.4/site-packages/pptx/parts/image.py in new(cls, package, image)
40 |Image| object.
41 """
---> 42 partname = package.next_image_partname(image.ext)
43 return cls(
44 partname, image.content_type, image.blob, package, image.filename

/data/ve/ttatt/lib/python3.4/site-packages/pptx/package.py in next_image_partname(self, ext)
83 return len(image_idxs)+1
84
---> 85 idx = first_available_image_idx()
86 return PackURI('/ppt/media/image%d.%s' % (idx, ext))
87

/data/ve/ttatt/lib/python3.4/site-packages/pptx/package.py in first_available_image_idx()
79 for i, image_idx in enumerate(image_idxs):
80 idx = i + 1
---> 81 if idx < image_idx:
82 return idx
83 return len(image_idxs)+1

TypeError: unorderable types: int() < NoneType()

demo.pptx
laughing-smiley-face-clip-art-smiley-face-clip-art10