Once there is no more data to encode then you should call the FinishEncoding function which will finish any buffered bytes that did not add up to pairs of 3, reset internal buffers and clean up.
Base64Stream Class