Easiest things is to wash/disinfect the surface before you carve, like give the pumpkin a nice bleachwater bath. Use clean tools & seal the cut edges with petrolium jelly or WD-40.
Long-term you probably could dry it as a gourd to preserve it, but it'll shrivel up a lot and look like shit.
Formaldehyde/pickling would also probably work, but i imagine it'd get all mushy.
Just this year I learnt you should carve out the top (stem) part. Apparently there's some nutrients/water, magic, or something, left in it; and if you leave it uncut it will help the rest of the pumpkin look better for longer.
Cut out the bottom, or a hole in the back, instead.