Creating an imagetable with too many items ends in segfault (low priority, nice to have)

An attempt to create an imagetable with more than 2^16 items crashes the Simulator. I guess the underlying code uses 16bit integers and this limit is more than reasonable, but it would be nice to have a gracious crash with an error instead of a segfault in Simulator.

I guess this would happen only with wrong input, or — as in my case — when using Sim for prerendering complex tilemaps. We use tiles flipped on both axes, so I hit the upper limit with a tileset that contained 150x120 tiles (x 4 after flipping).