Update Base64Encoder to use `bytes.length` instead of `encoded.length` when lopping over the bytes. Fixes gh-3314