This happend when you use the ECB or CBC modes, which need a whole multiple of blocks to pass to the encryption key. The size of the block depends on the key used and is returned by the CipherKey.plainBlockSize() method.
If less than a whole multiple of blocks has been sent to the EncryptECB or EncryptCBC object when flush() is called, random data will be appended to make certain attacks on the key more difficult.
Some possible solutions include sending the size of the message along with the message itself or making certain that the message size is a whole multiple of blocks. Alternatively, you may want to use either the CFB of OFB modes.