Moved where memory is allocated and freed in stencil_shift.

The idea was to avoid paging/thrashing, if possible, by not having both
tmp1 and tmp2 chunks of memory allocated at the same time for the entire
procedure. Both arrays are needed in Y-direction anti-blurring.