Fix forward transform for multiple threads
A global variable i used in the forward transform that prevents it
to be used by several threads in parallel.