Added support for invalid jpegs