Structural, electronic and optical properties of titania nanotubes