Heat the oven to 200°C, fan 180°C, gas 6. Melt the butter in a frying pan on a medium heat and fry the onion for 10 minutes, stirring frequently, until soft. Leave to cool. Season the beans; add the Tabasco and Worcestershire sauces. Tip into a pie dish (20cm wide x 7cm deep). Mix the cheese with the softened onions and season. Scatter over the top of the beans in the dish. Brush some of the egg onto the rim of the dish, then unroll the puff pastry over the top. Trim off the excess pastry.