Added support for encoding and decoding iTXt chunks.

This function uses a lot of single-letter variable names and it's not always clear what they do. Please could you use more descriptive names?