Handle ValueError during json.loads of json data from build

See #7367

When building an image from a Dockerfile, the first time the base image is downloaded from the index, that portion of the build step returns invalid JSON data that causes `json.loads` to raise a ValueError.

This pull request catches that exception and continues on, ignoring the parsing failure.

If for some reason we skip every iteration of looping through the stream and no `image_id` was set, indicate that an unknown error was encountered.