On the variational principle for the topological entropy of certain non-compact sets