Tunable Properties of Mg-Doped V2O5 Thin Films for Energy Applications: Li-Ion Batteries and Electrochromics