Preheat oven to 350 degrees. Place rack in middle of oven.
Place butter, chopped onions, salt and pepper in a sauce pan over medium heat. Cook just until onions are softened. Place soup, sour cream, 2 cups of the grated cheese in a large bowl.
Pour the cooked onion/butter mixture over the soup mixture in the bowl. Mix well.
Add grated potatoes. Fold ingredients together.
Pour the mixture into a 9x13 greased pan.
If using topping, spread the Panko or cornflake mixture or additional 1/2 cup of cheese over the top of the casserole and bake uncovered for30-40 minutes or until the casserole is bubbly and golden on top.