Dark energy perturbations in N-body simulations