The output file for all the algorithms (except unix crypt) when not used in
bare mode is:

3 bytes as: NULL + "m" + \2
1 byte the algorithm (the algorithm's number is defined in lib/mcrypt.h)
1 byte the algorithm's mode (CBC, ECB, CFB, OFB) (also in lib/mcrypt.h)
1 byte storing the mode in which mcrypt read the key. (8bit, 4bit or hash) (0,1,2)
20 bytes a salt if hash key mode is used or nulls if other mode is used.
20 bytes nulls. (reserved for future extensions)
blocksize bytes the IV 
 (if CBC,OFB, or CFB. In CBC the IV is encrypted, in OFB or CFB it is unencrypted)
x bytes encrypted data (x=k*blocksize, k=1,2...)
1 byte the number of bytes that didn't fit to the algorithm and were
  padded. (this byte does not exist in CFB and OFB modes) This
  number should be 0 <= x < blocksize
blocksize bytes the crc32 of the plaintext(encrypted) 
  (the first 32 bits of the encrypted text are the crc32)

blocksize is 8 bytes for DES, CAST, 3DES, Blowfish, GOST, TEA, Safer 
and 12 bytes for 3-way. 
