This was caused by PIL raising a zlib truncated stream error since we fed the parser with chunks instead of the whole image.