You can use CBC encryption with Mcrypt, and then encrypt the data segment at a time. Make sure that the segment has x times the block size of the cipher being used (for example, 16 bytes for AES). Encrypt the segment and take the last block of generated ciphertext and use it as IV for the next segment. The final segment should contain PKCS # 7 (many examples, including in the comments mcrypt_encrypt).
By linking the segments together, you get encrypted text indistinguishable from one encryption (check your code using this information). Decryption is identical using ciphertext as IV. To find out how this works, take a look at the CBC encryption method:

EDIT: , OpenSSL. () , , , , . , , .