Sheriff: Man taking selfies with gun fatally shoots himself