Abstracted a bunch of common code from wkb

There was a lot of duplication in the WKB dump functions; that's been
factored out with this update.