For imps, you need a weapon made out of steel or better.
When you hit the imp, you should see a message like 'your weapon is ineffective' (or something similar). That means, to hit that type of monster, you need a weapon made of a higher quality material.
I'd suggest just skipping the room with the imp in it, and come back after you've found a better weapon elsewhere in the dungeon.