Well, I solved it myself after some more debugging!!
Turns out that different connections were being used for creating the
temporary tables and checking the existence of the table. Temporary
tables, being connection specific, are not visible across connections.
The temporary tables, like all other tables, are also listed in
pg_tables.
Sorry for the trouble folks!!
Regards,
Vikas