Revert "Investigate why certain images crash the program"

This reverts commit 9b560891a6171d490cf7473d1646686c00b47b7d.

Also the palette indexes are now being written properly