The best and only way for full quality with keeping all it's layers is xcf, the gimp default, I believe. The only other way is gif, but it dumbs down the quality. Most places don't host .xcf images.
Any other format, such as PNG, will merge all layers together.