fix crash in new_nif for dimensions other than 3