Patch by Callum Lerwick. Fixed error during encoding using tile option in tcd.c