support legacy bignum encoding in arbitrary terms

adds encode/2 which takes a boolean indicating whether or not to encode bignums
using the legacy encoding. removes legacy_encode_bignum/1 since the same
functionality is supported by encode/2