Fixed bug in tex image generation which would reconstruct tex file using wrong code lengths