It is advised to purchase outgoing ferry passage upon just arriving at a port. Also advised is to buy from the particular ferry company rather than pay a service charge from an independent agent. It might be that the company sales are at the port. This becomes a concern when arriving in Mykonos and Santorini where the port is not convenient to the town and I might have to track the offices down, luggage in hand or possibly miss the transport to town while negotiating ticketing. My questions is: Are the company sales offices on these islands at the port or in town? For Mykonos the company is Superjet aka Sea jets central agent.
For Santorini the company is Blue Star aka Helenic seaways central agent.
You can buy those tickets via Direct Ferries. Select the UK site for English. Prices will be shown in local curreny, which in Greece's case is Euro. The reason for why buying upon arrival at the port in Greece is that you actually never really know if that one boat you prebooked ends up operating or not. But I'd give it the benefit of the doubt...
Generally you do not need to buy tickets very far ahead except in high season, and even then rarely. For both of those islands, I would just pick up tickets at an agency in town at your leisure, not much difference in price, if any, wherever you go.