Design of a general optical interconnection system with phase-only masks