When you book your train tickets on the vy.no website, your origin is Oslo S; your destination is Flam. Your ticket will show the two segments separately. You'll probably be able to choose seats on the train to Myrdal but not on the Flamsbana. The Vy website didn't like my credit card, so I used PayPal. Be sure you pay in NOK rather than in dollars.
If you want to take the ferry between Flam and Gudvangen, you should get that ticket in advance as well. NorwaysBest.com sells tickets on one of the ferry lines. You might be able to book a combination ticket that includes that ferry and the bus from Gudvangen to Voss. If not, it shouldn't be a problem. I just paid the bus driver (probably by tapping my credit card, but I really don't remember).
The conventional wisdom is that you don't need to pre-book the train from Voss to Bergen, but I got that ticket in advance from vy.no. If you don't have just time at Voss, why be stressed a out buying a train ticket?
Be sure you have accurate m information about the schedule for the express boat that connects Flam to Balestrand. That link only runs once a day in each direction.