fixed segfault, squareBuf is Uint not char
fixed tile loading code to be clean, and work for the general case