Make V2 code more defensive against malformed content

Added more checks in the V2 code against possible malformed or changed content.  This code will only be hit when pulling from the V2 registry, which is still only for official images.

Ping @crosbymichael