base58.cc: Fix many memory leaks

The code allocates the BN structure using the C library, so we must manually free all these bignums upon error.

The fix is ugly and uses (a) inline error handling in base58_encode(), and (b) goto-based error handling in base58_decode()

This is the best route to an obviously correct quick fix.

A better solution would be to import the CBigNum class from bitcoind, and let RAII and scope-closing automatically handle the bignum cleanups.  That would eliminate gotos and long, boring cleanup code in general.

It would also enable near-direct import of bitcoind's base58 routines, rather than reinventing them -- with bugs -- as done here.