Universal method for the synthesis of arbitrary polarization states radiated by a nanoantenna