Change how errors are handled.

Return errors from all methods that can fail instead of having a
separate method to check for an error.  This is more idiomatic Go, and
makes this easier to use.