Thanks for answering so quickly.
Another problem may be that NAimg2 goes out of scope before it gets used or DECREF'ed;
Bingo that was the problem. My SWIG typemap was declaring NAimg2 twice, and thats an error. The inner NAimg2 got the array data and was getting out of scope. The outer NAimg2 was being DECREF'ed, but it had NULL and nothing was happening. Thanks, I was staring this code for some time now and couldn't see the error. Once I read your message it took me half minute to find the problem and fix it. Paulo. Obs: I am CC the list, then everyone gets to know the solution.