は is the subject particle: It is used to mark the subject of the sentence, as in the thing that is is doing the verb of that sentence. 私は書きます-I am writing. が is the topic particle, this may sound similar to は the subject particle but they serve different functions. は is related grammatically to the verb of the sentence whereas が is not necessarily. Whatever you は is the thing that is doing the verb.が on the other hand gives a non-grammatical context to the sentence. 私は花が好きです-I like flowers: In this sentence the 私 (I) is the thing that 好き(likes) the flowers, the flowers are the context. This can be confusing however because が can also be used as a substitute for は in order to emphasise the thing it is attached to. To explain this lets look at the difference between these two sentences: 私はジェームズです- I am James. 私がジェームズです-I am James. The sentences seem to mean the same thing but they focus on different points, the が sentence emphasises 'I' whereas the は sentence has no emphasis. The は sentence is what you would use is someone asked 'what is your name?' 私はジェームズです-I am James, The が sentence on the other hand would be used as a reply to a question like: 'Who is James?' 私がジェームズです-I am James.