How to keep pumpkin fresh for a long time?
According to the National Center for Home Food Preservation (emphasis added):


  Freezing is the easiest way to preserve pumpkin, and it yields the
  best quality product. Select full-colored mature pumpkin with fine
  texture (not stringy or dry). Wash, cut into cooking-size sections and
  remove seeds. Cook until soft in boiling water, in steam, in a
  pressure cooker, or in an oven. Remove pulp from rind and mash. To
  cool, place pan containing pumpkin in cold water and stir occasionally
  (So Easy to Preserve, 2006). Pack into rigid containers leaving
  headspace, and freeze.


They offer suggest a variety of cooking methods before freezing the flesh of the pumpkin, but you may find that roasting offers the least work and best flavor development.

Pressure canning of cubed (but not mashed or pureed) pumpkin is also possible (as pumpkin is a low acid fruit, boiling water canning is not appropriate).   You should use only a trusted recipe if you choose to go this route.

You can also make pumpkin leather, although this does not to leave the pumpkin suitable for many recipes, and is only suitable if this the actual product you desire.