Energy harvesting performance and flow structure of an oscillating hydrofoil with finite span