Tamim Iqbal's first international century in three years was in vain as Sri Lanka beat Bangladesh by eight wickets in the first ODI in Hambantota.