Energy efficiency is crucial when wireless nodes are deployed in a remote or isolated area. This paper provides an optimal solution for data gathering from a wide area Wireless Sensor Network (WSN) with the use of Unmanned Aerial Vehicles (UAVs). Particle Swarm Optimization (PSO) is proposed as an optimization method to find the waypoints for a UAV in order to reduce the energy consumption and bit error rate (BER) of the sensor nodes, and the UAV travel time. In our previous work, the sensor nodes were required to transmit data to a Cluster Head (CH) node, which then forwarded the data to the UAV. The waypoints were restricted to be straight above the CH. In this work we employ cooperative relay, to make the data gathering more efficient. In addition, the waypoints of the UAV can be selected freely. To illustrate the effectiveness, we compare our new strategy to the one of our previous paper. Numerical results illustrate that the performance gap between them increases with the number of waypoints, in favor of the new strategy. Furthermore, the optimal number of waypoints for the UAV is also described, based on the size of the sensor network area and the density of the sensor node distribution. These contributions have maximized the network lifetime and communication quality, while minimized the UAV's flying time.