Cra 505

CRA-708: Fixed handling of padding when sampling into NRLib grid for background, and some meory allocation bugs in avoinversion.