Better error checking in texture loader