BASE64: applied OpenBSD's fix.
github-issue: #68
The overflow checks are handled differently. With some sized buffers, it was misled and returns an error while it should not be. Also, the wrting in the dest buffer is postponed once it is sure it has room for it.