Kosterlitz-thouless transition and self-duality in three dimensions