API v1 fixes

These fix up some of the showstopper bugs currently present in deis, as well as improving the output of the API in preparation for #1042.

fixes #2094
fixes #2105 

To note: these fixes do not support envvars that have spaces, such as `deis config:set HELLO="foo bar"`. I tried desperately but with no luck. I've been working on it all weekend with no resolution. If someone has a fix for that, I'd be very happy <3
I think we've officially outgrown bash here.  Have we considered shelling out to python to handle the structured data?