Modular invariant partition functions for parafermionic field theories