This is just a subset of the code found at https://github.com/contentful-labs/Concorde.
Download and decode progressive JPEGs on iOS.