Optimisation of free space optical communication for satellite and terrestrial applications