Use api for pulling images instead of shelling out

I've just copied the functions to parse and validate the repo name from Docker because otherwise this would require including the complete Docker sources.

/cc @brendandburns
Yes, that's a clean, simplified 'reimplementation' like pretty much all clients have it.