Yes, you should be consistent in your spelling. If you are writing in British English, then "flavor" is a mistake.
This shouldn't be much of a problem. The grammar of American and British English is very similar, particularly in the written forms of the language. Far more similar than the grammar of, for example, Castilian and Galician Spanish. The spelling can be easily checked by computer (you should set your preference to either British or American spelling, and you should always spellcheck anything you write on computer).
The other difference mattar less. If you are aware of particular American and British terminology, avoid saying "The automobile was parked on the pavement, with the hood open and the windscreen broken". But this sentence would be understood and, unless your thesis is about cars would not cause problems. There is a little variation in punctuation, but now this can usually also be checked by the computer. You will tend not to use idioms in a formal texts, if you are aware of an idiom being specifically from the "wrong" dialect then you should avoid it. Generally it is only casual idioms that are highly polarised by dialect, and you should be avoiding casual idioms anyway.
For handwritten texts do your best, but native speakers are generally more permissive of minor errors in handwritten texts that do not affect meaning or understanding.
In a scientific text it is more important to use the right technical terminology rather than worry about Americanisms/Britishisms. In a fiction text they would be more distracting.