Three-loop quark form factor at high energy: The leading mass corrections