An accurate cartesian method is devised to simulate incompressible viscous flows past an arbitrary moving body. The Navier-Stokes equations are spatially discretized onto a fixed Cartesian mesh. The body is taken into account via the ghost-cell method and the so-called penalty method, resulting in second-order accuracy in velocity. The accuracy and the efficiency of the solver are tested through two-dimensional reference simulations. To show the versatility of this scheme we simulate a three-dimensional self propelled jellyfish prototype.