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
Is this a clean implementation or a copy of Docker code?  Just concerned about copyright and attribution.