Fix bug when read() does not return a buffer of length 3n which caused the base64 stream to be truncated.