Tubular image states: General formulation and properties for metallic and nonmetallic nanotubes