Converting data structures between Erlang NIF and q