Inter Milan ensured it kept pace with Serie A leader Napoli after surviving a late surge to beat Empoli 3-1 at San Siro.